﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAO;
using Domain;

public partial class QR_Print : System.Web.UI.Page
{
    public long? idemp
    {
        get
        {
            long l = 0;
            if (Request.QueryString["idemp"] == null ||
               !long.TryParse(Request.QueryString["idemp"], out l) ||
               l <= 0)
                return null;
            return l;
        }
    }

    public long? idpub
    {
        get
        {
            long l = 0;
            if (Request.QueryString["idpub"] == null ||
               !long.TryParse(Request.QueryString["idpub"], out l) ||
               l <= 0)
                return null;
            return l;
        }
    }

    public string texto {
        get {
            string address = this.Request.Url.AbsoluteUri.Substring(0, this.Request.Url.AbsoluteUri.IndexOf(this.Request.Url.Segments[2]));

            if (idemp.HasValue)
                return System.IO.Path.Combine(address, "m_login.aspx?t=e&id=" + idemp.Value);

            if (idpub.HasValue)
                return System.IO.Path.Combine(address, "m_login.aspx?t=p&id=" + idpub.Value);
            
            return string.Empty;

        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            lbl_Empresa.Text = ((Empresa)Utils.operadorLogueado).RazonSocial;

            long emp = 0;
            if (idpub.HasValue)
            {
                Publicacion p = PublicacionDAO.Traer(idpub.Value, null, null).First();
                lbl_Publicacion.Text = p.Descripcion;
            }
        }
        catch { }
    }
}
